﻿using PlayerScannerCore.ViewModel;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace PlayerScanner
{
    public class StatusConditionsConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var ret = String.Empty;

            if (value != null)
            {
                var intValue =(int)value;

                if ((intValue & 0x01) == 0x01)
                    ret += (ret == String.Empty) ? "Pois" : "/Pois";
                if ((intValue & 0x02) == 0x02)
                    ret += (ret == String.Empty) ? "Para" : "/Para";
                if ((intValue & 0x04) == 0x04)
                    ret += (ret == String.Empty) ? "Shoc" : "/Shoc";
                if ((intValue & 0x08) == 0x08)
                    ret += (ret == String.Empty) ? "Slow" : "/Slow";
                if ((intValue & 0x16) == 0x10)
                    ret += (ret == String.Empty) ? "Conf" : "/Conf";
                if ((intValue & 0x32) == 0x20)
                    ret += (ret == String.Empty) ? "Frzn" : "/Frzn";

                if (ret == String.Empty)
                    ret = "None";
            }

            return ret;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            // Do nothing
            return null;
        }
    }
}
